package com.chiry.business.controller;

import com.chiry.business.entity.Result;
import com.chiry.business.remote.ObjStorageClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/business")
public class UploadFileController {
    public final static String BUCKET_NAME = "aws-cn-insect-images";
    @Autowired
    private ObjStorageClient objStorageClient;

    //@RequestPart("file") MultipartFile file, @RequestParam("fileType") Integer fileType, @RequestParam("bucketName") String bucketName
    @PostMapping("/upload/image")
    public Result<String> uploadImage(@RequestPart("file") MultipartFile file, @RequestParam("fileType") Integer fileType) {
        //bucketName 表示图片分类name
        Result<String> uploadResult = objStorageClient.upload(file, fileType, BUCKET_NAME);
        uploadResult.toString();
        return uploadResult;
    }

}
